<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class BorrowBook extends Model
{
    use HasFactory,HasDatetimeFormatter;

    protected $fillable = [
        'user_id',
        'book_id',
        'borrow_date',
        'return_date',
        'illegal',
        'status',
    ];

    const STATUS_ENUM = [
        '0' => '审批中',
        '1' => '借阅成功',
        '2' => '归还成功',
    ];

    // 审批中
    const STATUS_APPROVAL = 0;
    // 借阅成功
    const STATUS_BORROW = 1;
    // 归还
    const STATUS_RETURN = 2;


    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function book()
    {
        return $this->belongsTo(Book::class);
    }
}
